styleprovider: Fold get_change() vfunc into lookup()
authorBenjamin Otte <otte@redhat.com>
Tue, 9 Dec 2014 18:31:17 +0000 (19:31 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 10 Dec 2014 02:49:40 +0000 (03:49 +0100)
gtk/deprecated/gtkstyleproperties.c
gtk/gtkcssprovider.c
gtk/gtkmodifierstyle.c
gtk/gtksettings.c
gtk/gtkstylecascade.c
gtk/gtkstylecontext.c
gtk/gtkstyleproviderprivate.c
gtk/gtkstyleproviderprivate.h

index f61f7a2b6dd91604a9a188e0d3b2ff310d95ff4f..9cf29754eea96fbf5b96a2831afec97d757905e1 100644 (file)
@@ -300,7 +300,8 @@ gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
 static void
 gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
                                       const GtkCssMatcher     *matcher,
-                                      GtkCssLookup            *lookup)
+                                      GtkCssLookup            *lookup,
+                                      GtkCssChange            *change)
 {
   GtkStyleProperties *props;
   GtkStylePropertiesPrivate *priv;
@@ -331,13 +332,9 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
 
       _gtk_css_lookup_set (lookup, id, NULL, value);
     }
-}
 
-static GtkCssChange
-gtk_style_properties_provider_get_change (GtkStyleProviderPrivate *provider,
-                                          const GtkCssMatcher     *matcher)
-{
-  return GTK_CSS_CHANGE_STATE;
+  if (change)
+    *change = GTK_CSS_CHANGE_STATE;
 }
 
 static void
@@ -345,7 +342,6 @@ gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *if
 {
   iface->get_color = gtk_style_properties_provider_get_color;
   iface->lookup = gtk_style_properties_provider_lookup;
-  iface->get_change = gtk_style_properties_provider_get_change;
 }
 
 /* GtkStyleProperties methods */
index 6b02befcd40fe1630998e2c8678677d0be8d36e9..06755037ee4791489be51a0f219bb9c2c11a0c14 100644 (file)
@@ -1774,7 +1774,8 @@ gtk_css_style_provider_get_keyframes (GtkStyleProviderPrivate *provider,
 static void
 gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
                                const GtkCssMatcher     *matcher,
-                               GtkCssLookup            *lookup)
+                               GtkCssLookup            *lookup,
+                               GtkCssChange            *change)
 {
   GtkCssProvider *css_provider;
   GtkCssProviderPrivate *priv;
@@ -1819,24 +1820,16 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
     }
 
   g_ptr_array_free (tree_rules, TRUE);
-}
-
-static GtkCssChange
-gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                   const GtkCssMatcher     *matcher)
-{
-  GtkCssProvider *css_provider;
-  GtkCssProviderPrivate *priv;
-  GtkCssChange change;
 
-  css_provider = GTK_CSS_PROVIDER (provider);
-  priv = css_provider->priv;
-
-  change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
+  if (change)
+    {
+      GtkCssMatcher change_matcher;
 
-  verify_tree_get_change_results (css_provider, matcher, change);
+      _gtk_css_matcher_superset_init (&change_matcher, matcher, GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS);
 
-  return change;
+      *change = _gtk_css_selector_tree_get_change_all (priv->tree, &change_matcher);
+      verify_tree_get_change_results (css_provider, &change_matcher, *change);
+    }
 }
 
 static void
@@ -1845,7 +1838,6 @@ gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *ifa
   iface->get_color = gtk_css_style_provider_get_color;
   iface->get_keyframes = gtk_css_style_provider_get_keyframes;
   iface->lookup = gtk_css_style_provider_lookup;
-  iface->get_change = gtk_css_style_provider_get_change;
 }
 
 static void
index e09f67172c33cfc3377f85d32508cdd631adc5f4..1ea54d120fa6a603febe502f6baf0b2c320120d4 100644 (file)
@@ -118,23 +118,15 @@ gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
 static void
 gtk_modifier_style_provider_lookup (GtkStyleProviderPrivate *provider,
                                     const GtkCssMatcher     *matcher,
-                                    GtkCssLookup            *lookup)
+                                    GtkCssLookup            *lookup,
+                                    GtkCssChange            *change)
 {
   GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
 
   _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
                                       matcher,
-                                      lookup);
-}
-
-static GtkCssChange
-gtk_modifier_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                        const GtkCssMatcher     *matcher)
-{
-  GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
-
-  return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
-                                                 matcher);
+                                      lookup,
+                                      change);
 }
 
 static void
@@ -142,7 +134,6 @@ gtk_modifier_style_provider_private_init (GtkStyleProviderPrivateInterface *ifac
 {
   iface->get_color = gtk_modifier_style_provider_get_color;
   iface->lookup = gtk_modifier_style_provider_lookup;
-  iface->get_change = gtk_modifier_style_provider_get_change;
 }
 
 static void
index 180b42e074e5e945ec6950776827a4e2341a764e..f06f78a48474fb117348492a6588424938f263cf 100644 (file)
@@ -1716,14 +1716,6 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
 {
 }
 
-static GtkCssChange
-gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                       const GtkCssMatcher *matcher)
-{
-  return 0;
-}
-
-
 static GtkSettings *
 gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
 {
@@ -1734,7 +1726,6 @@ static void
 gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
 {
   iface->get_settings = gtk_settings_style_provider_get_settings;
-  iface->get_change = gtk_settings_style_provider_get_change;
 }
 
 static void
index d4216f19dc3734b8accf298612b7ab45a02512e3..dd34aa18f80054b7d9a1bcb9160d7d9dfafae8d7 100644 (file)
@@ -201,11 +201,13 @@ gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider,
 static void
 gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
                           const GtkCssMatcher     *matcher,
-                          GtkCssLookup            *lookup)
+                          GtkCssLookup            *lookup,
+                          GtkCssChange            *change)
 {
   GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
   GtkStyleCascadeIter iter;
   GtkStyleProvider *item;
+  GtkCssChange iter_change;
 
   for (item = gtk_style_cascade_iter_init (cascade, &iter);
        item;
@@ -215,7 +217,10 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
         {
           _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (item),
                                               matcher,
-                                              lookup);
+                                              lookup,
+                                              change ? &iter_change : NULL);
+          if (change)
+            *change |= iter_change;
         }
       else
         {
@@ -225,33 +230,6 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
     }
 }
 
-static GtkCssChange
-gtk_style_cascade_get_change (GtkStyleProviderPrivate *provider,
-                              const GtkCssMatcher     *matcher)
-{
-  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
-  GtkStyleCascadeIter iter;
-  GtkStyleProvider *item;
-  GtkCssChange change = 0;
-
-  for (item = gtk_style_cascade_iter_init (cascade, &iter);
-       item;
-       item = gtk_style_cascade_iter_next (cascade, &iter))
-    {
-      if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
-        {
-          change |= _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (item),
-                                                            matcher);
-        }
-      else
-        {
-          g_return_val_if_reached (GTK_CSS_CHANGE_ANY);
-        }
-    }
-
-  return change;
-}
-
 static void
 gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
 {
@@ -259,7 +237,6 @@ gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface
   iface->get_settings = gtk_style_cascade_get_settings;
   iface->get_keyframes = gtk_style_cascade_get_keyframes;
   iface->lookup = gtk_style_cascade_lookup;
-  iface->get_change = gtk_style_cascade_get_change;
 }
 
 G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,
index 8205ec807e3f195692f0bcc5411aeca860c125d3..6bd35c75540f136463950686d27d2796e425dab9 100644 (file)
@@ -670,7 +670,8 @@ static void
 build_properties (GtkStyleContext             *context,
                   GtkCssComputedValues        *values,
                   const GtkCssNodeDeclaration *decl,
-                  const GtkBitmask            *relevant_changes)
+                  const GtkBitmask            *relevant_changes,
+                  GtkCssChange                *out_change)
 {
   GtkStyleContextPrivate *priv;
   GtkCssMatcher matcher;
@@ -685,7 +686,8 @@ build_properties (GtkStyleContext             *context,
   if (_gtk_css_matcher_init (&matcher, path))
     _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
                                         &matcher,
-                                        lookup);
+                                        lookup,
+                                        out_change);
 
   _gtk_css_lookup_resolve (lookup, 
                            GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
@@ -724,11 +726,17 @@ style_values_lookup (GtkStyleContext *context)
 
   style_info_set_values (info, values);
   if (gtk_style_context_is_saved (context))
-    g_hash_table_insert (priv->style_values,
-                         gtk_css_node_declaration_ref (info->decl),
-                         g_object_ref (values));
-  
-  build_properties (context, values, info->decl, NULL);
+    {
+      g_hash_table_insert (priv->style_values,
+                           gtk_css_node_declaration_ref (info->decl),
+                           g_object_ref (values));
+    
+      build_properties (context, values, info->decl, NULL, NULL);
+    }
+  else
+    {
+      build_properties (context, values, info->decl, NULL, &priv->relevant_changes);
+    }
 
   g_object_unref (values);
 
@@ -751,7 +759,7 @@ style_values_lookup_for_state (GtkStyleContext *context,
   decl = gtk_css_node_declaration_ref (context->priv->info->decl);
   gtk_css_node_declaration_set_state (&decl, state);
   values = _gtk_css_computed_values_new ();
-  build_properties (context, values, decl, NULL);
+  build_properties (context, values, decl, NULL, NULL);
   gtk_css_node_declaration_unref (decl);
 
   return values;
@@ -2638,7 +2646,7 @@ gtk_style_context_update_cache (GtkStyleContext  *context,
       changes = _gtk_css_computed_values_compute_dependencies (values, parent_changes);
 
       if (!_gtk_bitmask_is_empty (changes))
-       build_properties (context, values, decl, changes);
+       build_properties (context, values, decl, changes, NULL);
 
       _gtk_bitmask_free (changes);
     }
@@ -2694,31 +2702,7 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext  *context,
 
   /* Try to avoid invalidating if we can */
   if (change & GTK_STYLE_CONTEXT_RADICAL_CHANGE)
-    {
-      priv->relevant_changes = GTK_CSS_CHANGE_ANY;
-    }
-  else
-    {
-      if (priv->relevant_changes == GTK_CSS_CHANGE_ANY)
-        {
-          GtkWidgetPath *path;
-          GtkCssMatcher matcher, superset;
-
-          path = create_query_path (context, priv->info->decl);
-          if (_gtk_css_matcher_init (&matcher, path))
-            {
-              _gtk_css_matcher_superset_init (&superset, &matcher, GTK_STYLE_CONTEXT_RADICAL_CHANGE & ~GTK_CSS_CHANGE_SOURCE);
-              priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
-                                                                               &superset);
-            }
-          else
-            priv->relevant_changes = 0;
-
-          priv->relevant_changes &= ~GTK_STYLE_CONTEXT_RADICAL_CHANGE;
-
-          gtk_widget_path_unref (path);
-        }
-    }
+    return TRUE;
 
   if (priv->relevant_changes & change)
     return TRUE;
@@ -2837,7 +2821,7 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     {
       changes = _gtk_css_computed_values_compute_dependencies (current, parent_changes);
       if (!_gtk_bitmask_is_empty (changes))
-       build_properties (context, current, info->decl, changes);
+       build_properties (context, current, info->decl, changes, NULL);
 
       gtk_style_context_update_cache (context, parent_changes);
     }
index 1f62b88807fb5d93a8a09fa88f299b3f95583837..35a6f6e0f6483e2ae9023c3de92cf3b9ccf28def 100644 (file)
@@ -84,7 +84,8 @@ _gtk_style_provider_private_get_keyframes (GtkStyleProviderPrivate *provider,
 void
 _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
                                     const GtkCssMatcher     *matcher,
-                                    GtkCssLookup            *lookup)
+                                    GtkCssLookup            *lookup,
+                                    GtkCssChange            *out_change)
 {
   GtkStyleProviderPrivateInterface *iface;
 
@@ -92,29 +93,15 @@ _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
   g_return_if_fail (matcher != NULL);
   g_return_if_fail (lookup != NULL);
 
+  if (out_change)
+    *out_change = 0;
+
   iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
 
   if (!iface->lookup)
     return;
 
-  iface->lookup (provider, matcher, lookup);
-}
-
-GtkCssChange
-_gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider,
-                                        const GtkCssMatcher     *matcher)
-{
-  GtkStyleProviderPrivateInterface *iface;
-
-  g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), GTK_CSS_CHANGE_ANY);
-  g_return_val_if_fail (matcher != NULL, GTK_CSS_CHANGE_ANY);
-
-  iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
-
-  if (!iface->get_change)
-    return GTK_CSS_CHANGE_ANY;
-
-  return iface->get_change (provider, matcher);
+  iface->lookup (provider, matcher, lookup, out_change);
 }
 
 void
index c619d8d75b0516a1fe56f7fe33c322613ebeca13..a66e1860882985e329f90110cd599f8da5dd95f0 100644 (file)
@@ -46,9 +46,8 @@ struct _GtkStyleProviderPrivateInterface
                                                  const char              *name);
   void                  (* lookup)              (GtkStyleProviderPrivate *provider,
                                                  const GtkCssMatcher     *matcher,
-                                                 GtkCssLookup            *lookup);
-  GtkCssChange          (* get_change)          (GtkStyleProviderPrivate *provider,
-                                                 const GtkCssMatcher     *matcher);
+                                                 GtkCssLookup            *lookup,
+                                                 GtkCssChange            *out_change);
 
   /* signal */
   void                  (* changed)             (GtkStyleProviderPrivate *provider);
@@ -63,9 +62,8 @@ GtkCssKeyframes *       _gtk_style_provider_private_get_keyframes(GtkStyleProvid
                                                                   const char              *name);
 void                    _gtk_style_provider_private_lookup       (GtkStyleProviderPrivate *provider,
                                                                   const GtkCssMatcher     *matcher,
-                                                                  GtkCssLookup            *lookup);
-GtkCssChange            _gtk_style_provider_private_get_change   (GtkStyleProviderPrivate *provider,
-                                                                  const GtkCssMatcher     *matcher);
+                                                                  GtkCssLookup            *lookup,
+                                                                  GtkCssChange            *out_change);
 
 void                    _gtk_style_provider_private_changed      (GtkStyleProviderPrivate *provider);